﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace System.Reflection
{
    public static class MemberInfoExtension
    {
        public static IEnumerable<T> Attributes<T>(this MemberInfo memberInfo) where T : Attribute
        {
            return memberInfo.GetCustomAttributes(typeof(T), true).Cast<T>();
        }
        public static T Attribute<T>(this MemberInfo memberInfo) where T : Attribute
        {
            return memberInfo.Attributes<T>().FirstOrDefault();
        }
    }
}
